package main

import (
	"fmt"
	"gitee.com/fierce_wolf/go-fox-edge-common/Initialize"
	"gitee.com/fierce_wolf/go-fox-edge-common/commEntity"
	"gitee.com/fierce_wolf/go-fox-edge-common/commMqtt"
	"gitee.com/fierce_wolf/go-fox-edge-common/commUtil/periodTask"
	mqtt "github.com/eclipse/paho.mqtt.golang"
	"time"
)

func Handler(clientId string) mqtt.MessageHandler {
	return func(client mqtt.Client, msg mqtt.Message) {
		fmt.Println(clientId + " " + string(msg.Topic()))
	}
}

func main() {
	Initialize.Initialize()
	commEntity.GetPoReflectType(commEntity.Type.DeviceEntity.Type())

	client := commMqtt.NewClient("/neuron/100120")
	client.Connect()
	client.Subscribe("/166/D1MS032EJ613/function/get", Handler("/neuron/100120"))

	client = commMqtt.NewClient("/neuron/111")
	client.Connect()
	client.Subscribe("/166/D1MS032EJ613/function/get", Handler("/neuron/111"))

	periodTask.InsertTask(commMqtt.AutoTask)
	periodTask.Scheduler()

	// os.Args是一个字符串切片，其中第一个元素是程序本身的路径，其余元素是传入的参数
	//	args := os.Args

	//// 打印所有参数
	//for i, arg := range args {
	//
	//	//fmt.Println("参数", i, "是:", arg)
	//}

	for true {
		time.Sleep(10 * time.Second)
	}

}
